﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TYRTUBase
{
    public abstract class ITYClient
    {

        public virtual string ParaKey()
        {
            return "";
        }

        public event DelegateOnComDataSend OnComDataSend;

        public event DelegateOnComDataRead OnComDataRead;


        public void FireOnComDataSend(ITYClient sender, byte[] data)
        {
            OnComDataSend?.Invoke(sender, data);
        }

        public void FireOnComDataRead(ITYClient sender, byte[] data)
        {
            OnComDataRead?.Invoke(sender, data);
        }


        public abstract bool ClearInBuff();

        public abstract bool Connect();

        public abstract void Close();

        public abstract int Write(byte[] byteData, int offset = 0, int length = -1);

        public abstract int Read(out byte[] byteData, int length = -1);

        public abstract string GetInfo();

        //后续处理得到当前参数的消息,例如端口等消息
        public abstract string GetPara();

        public abstract bool IsConnected { get; }

    }
}
